<div class="row">
	<div clsss="col-xs-12">
		<div class="clearfix" style="text-align: right; padding-right: 12px;">
			<div class="btn-group" role="group" aria-label="First group">
				<button type="button" class="btn btn-default"><i class="fa fa-search"></i></button>
				<button type="button" class="btn btn-default"><i class="fa fa-plus"></i></button>
				<button type="button" class="btn btn-default"><i class="fa fa-file-excel-o"></i></button>
				<button type="button" class="btn btn-default"><i class="fa fa-refresh"></i></button>
			</div>
		</div>
	</div>
</div>
<div class="row" style="margin-top: 10px;">
	<div class="col-xs-12">
		<?php if(isset($items) && $items){ ?>
		<table id="simple-table" class="table table-striped table-bordered table-hover">
			<thead>
				<tr>
					<th class="center">
						<label class="pos-rel">
							<input type="checkbox" class="ace">
							<span class="lbl"></span>
						</label>
					</th>
                        <th>ID</th>
                        <th>车型名称</th>
                        <th>车型英文名称</th>
                        <th>车型含义</th>
                        <th>创建时间</th>
                        <th>操作</th>
                    </tr>
				</tr>
			</thead>

			<tbody>
				<?php foreach ($items as $key => $value) { ?>
				<tr data-id="<?php echo $value->id;?>">
					<td class="center">
						<label class="pos-rel">
							<input type="checkbox" class="ace" value="<?php echo $value->id;?>">
							<span class="lbl"></span>
						</label>
					</td>
					<td><?php echo $value->id; ?></td>
					<td>
						<img src="<?php echo $value->thumbnail; ?>" alt="<?php echo $value->title;?>" style="width:100px;"/><br>
						<?php echo $value->title; ?>
					</td>
					<td><?php echo $value->title_en; ?></td>
					<td><?php echo $value->sub_title; ?></td>
					<td><?php echo date('Y-m-d H:i:s', $value->created_at); ?></td>
					<td>
						<div class="hidden-sm hidden-xs btn-group">
							<a href="/admin/car/save/<?php echo $value->id; ?>" class="btn btn-xs btn-info" title="编辑">
								<i class="ace-icon fa fa-pencil bigger-120"></i>
							</a>

							<a class="btn btn-xs btn-danger" title="删除" data-toggle="modal" data-target="#confirmModal">
                                <i class="ace-icon fa fa-trash-o bigger-120"></i>
                            </a>
						</div>

						<div class="hidden-md hidden-lg">
							<div class="inline pos-rel">
								<button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown" data-position="auto">
									<i class="ace-icon fa fa-cog icon-only bigger-110"></i>
								</button>

								<ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
									<li>
										<a href="#" class="tooltip-info" data-rel="tooltip" title="" data-original-title="View">
											<span class="blue">
												<i class="ace-icon fa fa-qrcode bigger-120"></i>
											</span>
										</a>
									</li>

									<li>
										<a href="#" class="tooltip-success" data-rel="tooltip" title="" data-original-title="Edit">
											<span class="green">
												<i class="ace-icon fa fa-bar-chart bigger-120"></i>
											</span>
										</a>
									</li>

									<li>
										<a href="#" class="tooltip-error" data-rel="tooltip" title="" data-original-title="Delete">
											<span class="red">
												<i class="ace-icon fa fa-pencil bigger-120"></i>
											</span>
										</a>
									</li>

									<li>
										<a href="#" class="tooltip-error" data-rel="tooltip" title="" data-original-title="Delete">
											<span class="red">
												<i class="ace-icon fa fa-trash-o bigger-120"></i>
											</span>
										</a>
									</li>
								</ul>
							</div>
						</div>
					</td>
				</tr>
				<?php } ?>
			</tbody>
			<?php if(isset($pagination) && $pagination){ ?>
			<tfoot>
				<tr>
					<td colspan="9" style="text-align: right;">
						<?php echo isset($pagination) && $pagination ? htmlspecialchars_decode($pagination) : ''; ?>
					</td>
				</tr>
			</tfoot>
			<?php } ?>
		</table>
		<?php }else{ ?>
		<div style="border: 1px solid #e0e0e0; line-height: 300px; width: 100%; text-align: center;">
			未找到相关数据
		</div>
		<?php } ?>
	</div><!-- /.span -->
</div>
<?php echo render('ace/public/alert_message'); ?>
<?php echo render('ace/public/confirm_modal'); ?>
<script type="text/javascript">
//触发删除对象的a标签
var a;
//确认删除后的回调方法
function confirmDelete(result) {
	if(result) {
        var i = $(a).find('i');
        var self = $(a).parents('tr');

        $(a).addClass('disabled');
        $(i).addClass('fa-spinner').addClass('fa-spin').removeClass('fa-trash-o');

        $.get('/admin/car/delete/' + self.attr('data-id'), 
            function(data, status){
                $(a).removeClass('disabled');
                $(i).removeClass('fa-spinner').removeClass('fa-spin').addClass('fa-trash-o');
                if(data.status == 'err'){
                    showResultMessage('删除失败', '', 'danger');
                    return;
                }
                showResultMessage('删除成功', '', 'success');
                self.remove();
            }, 'json');
	}
}
</script>